﻿using AutoTest.Business.Dto.AdminUser;
using AutoTest.Business.IServices;
using AutoTest.Business.Vo.AdminUser;
using AutoTest.Framework.Api;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace AutoTest.WebApi.Controllers.Admin
{
    /// <summary>
    /// 用户登录
    /// </summary>
    [Route("admin")]
    public class AdminUserController(IAdminUserService adminUserService) : Controller
    {
        private readonly IAdminUserService _adminUserService = adminUserService;

        /// <summary>
        /// 授权回调提交接口
        /// </summary>
        /// <param name="loginDto">用户登录信息</param>
        /// <returns></returns>
        [HttpPost("login")]
        [AllowAnonymous]
        public async Task<ApiResult<AdminLoginVo>> Login([FromBody] AdminUserLoginDto loginDto)
        {
            return await ApiResult<AdminLoginVo>.Successed(() => _adminUserService.LoginUser(loginDto));
        }
    }
}
